home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20000824-20010305
/
000364_news@columbia.edu _Mon Feb 26 09:47:02 2001.msg
< prev
next >
Wrap
Internet Message Format
|
2001-03-05
|
3KB
Return-Path: <news@columbia.edu>
Received: from watsun.cc.columbia.edu (watsun.cc.columbia.edu [128.59.39.2])
by fozimane.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id JAA18284
for <kermit.misc@cpunix.cc.columbia.edu>; Mon, 26 Feb 2001 09:46:33 -0500 (EST)
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id JAA07247
for <kermit.misc@watsun.cc.columbia.edu>; Mon, 26 Feb 2001 09:46:32 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id JAA22542
for kermit.misc@watsun.cc.columbia.edu; Mon, 26 Feb 2001 09:26:25 -0500 (EST)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: fdc@columbia.edu (Frank da Cruz)
Subject: Re: FTP scripting...
Date: 26 Feb 2001 14:26:24 GMT
Organization: Columbia University
Message-ID: <97dp2g$m0b$1@newsmaster.cc.columbia.edu>
To: kermit.misc@columbia.edu
In article <3A9A0C8C.4D85005C@fujitsu-siemens.com>,
Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
: Grant Edwards wrote:
: > In article <wkbsruo94c.fsf@mail.hex.net>, cbbrowne@hex.net wrote:
: > >>>>>> "Rene Scheibe <Rene.Scheibe@gmx.net> writes:
: > > Rene> ....can someone tell me if the normal ftp-client is
: > > Rene> scriptable??? How can I write a script for it. Can you
: > > Rene> give me an example??? I want to login to a server and put
: > > Rene> a file on it.
: > >
: > >You might try something like the following:
: > >
: > >#!/bin/ksh
: > >ftp -n 172.28.211.99 << EOD
: > > user cbbrowne MySecretPassword
: > > cd /tmp
: > > binary
: > > put somefile.txt
: > > bye
: > >EOD
: ... or look at the netrc concept. I've written a number of scripts that
: generate .netrc files on-the-fly and remove them when the access is
: done.
:
That's exactly why .netrc is not such a great idea. It's the tail wagging
the dog; you really want it the other way around -- an FTP client that can
run any script you want without having to change (and remember to put back)
some magic file.
Here's how you would do it with the new C-Kermit FTP client:
#!/usr/local/bin/kermit
ftp 172.28.211.99 /user:cbbrowne /password:MySecretPassword
if fail exit 1 FTP connection failed
ftp cd /tmp
if fail exit 1 FTP CD failed
put /binary somefile.txt
if fail exit 1 FTP PUT failed
bye
Note that each operation can be checked for failure. Also note that it's
not a great idea to put passwords in files, so you can have Kermit prompt
you for the password:
ftp 172.28.211.99 /user:cbbrowne
if fail exit 1 FTP connection failed
Just leave out the password and the prompting occurs automatically.
Of course if you want the script to run unattended, prompting for the
password is not practical, but there are ways around that too.
By the way, this is a very simple application for FTP scripting. So
simple, in fact, that Kermit can do it without a script. If you have a
symlink "ftp" to the C-Kermit 7.1 binary, you can just give it this
command line:
ftp 172.28.211.99 -u cbbrowne -P MySecretPassword -D /tmp -p somefile.txt
For more demanding examples, see:
http://www.columbia.edu/kermit/ftpscript.html
- Frank